package com.mifengkong.frtools.http.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.mifengkong.frtools.R;


/**
 * Created by jiangyongxing on 2017/5/24.
 * 描述：
 */

public class LoadingDialog extends Dialog {

    public LoadingDialog(Context context) {
        super(context);
    }

    public LoadingDialog(Context context, int theme) {
        super(context, theme);
    }

    public static class Builder {

        private Activity activity;
        private LoadingDialog mDialog;
        private TextView mLoadingTv;
        private String mLoadingTip;


        public Builder(Activity activity) {
            this.activity = activity;
        }

        public Builder setMessage(String loadingMassage) {
            this.mLoadingTip = loadingMassage;
            return this;
        }

        /**
         * Create the custom dialog
         */
        public LoadingDialog create() {
            mDialog = new LoadingDialog(activity, R.style.dialog_http_progress);
            mDialog.setContentView(R.layout.progress_dialog);

            mLoadingTv = mDialog.findViewById(R.id.message);
            ProgressBar progressBar = mDialog.findViewById(R.id.progressbar);
            if (!TextUtils.isEmpty(mLoadingTip))
                mLoadingTv.setText(mLoadingTip);
            return mDialog;
        }


    }

}
